package com.egg.ylt.activity;

import android.net.http.SslError;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.SslErrorHandler;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;

import com.alibaba.fastjson.JSON;
import com.egg.ylt.R;
import com.egg.ylt.adapter.ADA_ShopDetailTeacher;
import com.egg.ylt.adapter.ADA_TeacherList;
import com.egg.ylt.fragment.FRA_GrowUpCurve;
import com.egg.ylt.pojo.NatatoriumByidEntity;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.yonyou.framework.library.base.BaseActivity;
import com.yonyou.framework.library.base.BaseAppCompatActivity;
import com.yonyou.framework.library.bean.ErrorBean;
import com.yonyou.framework.library.common.log.Elog;

import java.util.List;

import butterknife.BindView;

/**
 * Created by lijiateng on 2019/2/26.
 */

public class ACT_Test extends BaseActivity {

//    @BindView(R.id.rv_server)
//    RecyclerView rvServer;

    @Override
    public void showBusinessError(ErrorBean error) {

    }

    @Override
    protected boolean isApplyKitKatTranslucency() {
        return false;
    }

    @Override
    protected void getBundleExtras(Bundle extras) {

    }

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.act_test;
    }

    @Override
    protected View getLoadingTargetView() {
        return null;
    }

    @Override
    protected void initViewsAndEvents() {

//        String json = "[{\"imageUrl\":\"https://sd-picture-oss.oss-cn-beijing.aliyuncs.com/bb106805-9d4d-4889-96e7-fcb9b4aa14ef.jpg\",\"id\":\"EF69E39B2C0000009EA800000022E000\",\"name\":\"张云\", \"experience\":\"3年\"},{\"imageUrl\":\"https://sd-picture-oss.oss-cn-beijing.aliyuncs.com/bb106805-9d4d-4889-96e7-fcb9b4aa14ef.jpg\",\"id\":\"EF69E39B300000009EA800000022E000\",\"name\":\"张云\", \"experience\":\"3年\"},{\"imageUrl\":\"https://sd-picture-oss.oss-cn-beijing.aliyuncs.com/bb106805-9d4d-4889-96e7-fcb9b4aa14ef.jpg\",\"id\":\"EF69E39B380000009EA800000022E000\",\"name\":\"张云\", \"experience\":\"3年\"},{\"imageUrl\":\"https://sd-picture-oss.oss-cn-beijing.aliyuncs.com/bb106805-9d4d-4889-96e7-fcb9b4aa14ef.jpg\",\"id\":\"EF69E39B400000009EA800000022E000\",\"name\":\"张云\", \"experience\":\"3年\"},{\"imageUrl\":\"https://sd-picture-oss.oss-cn-beijing.aliyuncs.com/bb106805-9d4d-4889-96e7-fcb9b4aa14ef.jpg\",\"id\":\"EF69E39B480000009EA800000022E000\",\"name\":\"张云\", \"experience\":\"3年\"}]";
//
////        RecyclerView rvServer = findViewById(R.id.rv_server);
//        ADA_ShopDetailTeacher teacherAdapter = new ADA_ShopDetailTeacher(mContext);
//
//        LinearLayoutManager layoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false);
////        rvServer.setAutofilled(true);
//        rvServer.setLayoutManager(layoutManager);
//        rvServer.setAdapter(teacherAdapter);
//
//
//        List<NatatoriumByidEntity.TeacherListBean> teacherListBeans = JSON.parseArray(json, NatatoriumByidEntity.TeacherListBean.class);
//        teacherAdapter.update(teacherListBeans, true);

        WebView wbCurve = findViewById(R.id.web_view);
        wbCurve.setWebChromeClient(new WebChromeClient());
        wbCurve.getSettings().setUseWideViewPort(true);

        WebSettings settings = wbCurve.getSettings();
        settings.setUseWideViewPort(true);
//        settings.setLoadWithOverviewMode(true);

        wbCurve.getSettings().setJavaScriptEnabled(true);
        wbCurve.getSettings().setSupportMultipleWindows(true);
        wbCurve.getSettings().setSupportZoom(true);
        wbCurve.getSettings().setBuiltInZoomControls(true);
        wbCurve.getSettings().setDisplayZoomControls(false);
        wbCurve.getSettings().setCacheMode(wbCurve.getSettings().LOAD_NO_CACHE);
        settings.setDomStorageEnabled(true);
        settings.setAppCacheEnabled(false);
        wbCurve.setVerticalScrollBarEnabled(false);

        wbCurve.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
//                view.loadUrl("http://192.168.98.95:9995");

                return true;
            }
            @Override
            public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
                handler.proceed();
            }
        });
//        webView.loadUrl("http://192.168.98.95:9995?id="+ mShopId +"/#/playNotice");
//        webView.loadUrl("http://www.baidu.com");
        wbCurve.loadUrl("http://192.168.98.95:9995");


    }

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return false;
    }

    @Override
    protected boolean isBindEventBusHere() {
        return false;
    }

    @Override
    protected boolean toggleOverridePendingTransition() {
        return false;
    }

    @Override
    protected TransitionMode getOverridePendingTransitionMode() {
        return null;
    }
}
